/*
* Copyright 2023 NXP
* NXP Confidential and Proprietary. This software is owned or controlled by NXP and may only be used strictly in
* accordance with the applicable license terms. By expressly accepting such terms or by downloading, installing,
* activating and/or otherwise using the software, you are agreeing that you have read, and that you agree to
* comply with and are bound by, such license terms.  If you do not agree to be bound by the applicable license
* terms, then you may not retain, install, activate or otherwise use the software.
*/

#include "events_init.h"
#include <stdio.h>
#include "lvgl.h"
#include "fsl_debug_console.h"

static void datetime_charge_handler(lv_event_t *e)
{
	lv_event_code_t code = lv_event_get_code(e);
	switch (code)
	{
	case LV_EVENT_VALUE_CHANGED:
	{
		lv_obj_t * obj = lv_event_get_target(e);
		char * user_data = lv_event_get_param(e);
		lv_label_set_text(obj,user_data);
	}
		break;
	default:
		break;
	}
}
static void deviceid_charge_handler(lv_event_t *e)
{
	lv_event_code_t code = lv_event_get_code(e);
	switch (code)
	{
	case LV_EVENT_VALUE_CHANGED:
	{
		lv_obj_t * obj = lv_event_get_target(e);
		char * user_data = lv_event_get_param(e);
		lv_label_set_text(obj,user_data);
	}
		break;
	default:
		break;
	}
}
static void personid_charge_handler(lv_event_t *e)
{
	lv_event_code_t code = lv_event_get_code(e);
	switch (code)
	{
	case LV_EVENT_VALUE_CHANGED:
	{
		lv_obj_t * obj = lv_event_get_target(e);
		char * user_data = lv_event_get_param(e);
		lv_label_set_text(obj,user_data);
		
	}
		break;
	default:
		break;
	}
}
static void weldid_charge_handler(lv_event_t *e)
{
	lv_event_code_t code = lv_event_get_code(e);
	switch (code)
	{
	case LV_EVENT_VALUE_CHANGED:
	{
		lv_obj_t * obj = lv_event_get_target(e);
		char * user_data = lv_event_get_param(e);
		lv_label_set_text(obj,user_data);
	}
		break;
	default:
		break;
	}
}
static void direction_charge_handler(lv_event_t *e)
{
	lv_event_code_t code = lv_event_get_code(e);
	switch (code)
	{
	case LV_EVENT_VALUE_CHANGED:
	{
		lv_obj_t * obj = lv_event_get_target(e);
		char * user_data = lv_event_get_param(e);
		lv_label_set_text(obj,user_data);
	}
		break;
	default:
		break;
	}
}
static void weldlayer_charge_handler(lv_event_t *e)
{
	lv_event_code_t code = lv_event_get_code(e);
	switch (code)
	{
	case LV_EVENT_VALUE_CHANGED:
	{
		lv_obj_t * obj = lv_event_get_target(e);
		char * user_data = lv_event_get_param(e);
		lv_label_set_text(obj,user_data);
	
	}
		break;
	default:
		break;
	}
}
static void angle_charge_handler(lv_event_t *e)
{
	lv_event_code_t code = lv_event_get_code(e);
	switch (code)
	{
	case LV_EVENT_VALUE_CHANGED:
	{
		lv_obj_t * obj = lv_event_get_target(e);
		char * user_data = lv_event_get_param(e);
		lv_label_set_text(obj,user_data);
	}
		break;
	default:
		break;
	}
}
static void voltage_charge_handler(lv_event_t *e)
{
	lv_event_code_t code = lv_event_get_code(e);
	switch (code)
	{
	case LV_EVENT_VALUE_CHANGED:
	{
		lv_obj_t * obj = lv_event_get_target(e);
		uint32_t  user_data = lv_event_get_param(e);
		char user_data_char[10];
		sprintf(user_data_char,"%d",user_data);
		lv_label_set_text(obj,user_data_char);
	}
		break;
	default:
		break;
	}
}
static void current_charge_handler(lv_event_t *e)
{
	lv_event_code_t code = lv_event_get_code(e);
	switch (code)
	{
	case LV_EVENT_VALUE_CHANGED:
	{
		lv_obj_t * obj = lv_event_get_target(e);
		uint32_t  user_data = lv_event_get_param(e);
		char user_data_char[10];
		sprintf(user_data_char,"%d",user_data);
		lv_label_set_text(obj,user_data_char);
	}
		break;
	default:
		break;
	}
}
static void weldspeed_charge_handler(lv_event_t *e)
{
	lv_event_code_t code = lv_event_get_code(e);
	switch (code)
	{
	case LV_EVENT_VALUE_CHANGED:
	{
		lv_obj_t * obj = lv_event_get_target(e);
		uint32_t  user_data = lv_event_get_param(e);
		char user_data_char[10];
		sprintf(user_data_char,"%d",user_data);
		lv_label_set_text(obj,user_data_char);
	}
		break;
	default:
		break;
	}
}
static void letspeed_charge_handler(lv_event_t *e)
{
	lv_event_code_t code = lv_event_get_code(e);
	switch (code)
	{
	case LV_EVENT_VALUE_CHANGED:
	{
		lv_obj_t * obj = lv_event_get_target(e);
		uint32_t  user_data = lv_event_get_param(e);
		char user_data_char[10];
		sprintf(user_data_char,"%d",user_data);
		lv_label_set_text(obj,user_data_char);
	}
		break;
	default:
		break;
	}
}
static void hotinput_charge_handler(lv_event_t *e)
{
	lv_event_code_t code = lv_event_get_code(e);
	switch (code)
	{
	case LV_EVENT_VALUE_CHANGED:
	{
		lv_obj_t * obj = lv_event_get_target(e);
		uint32_t  user_data = lv_event_get_param(e);
		char user_data_char[10];
		sprintf(user_data_char,"%d",user_data);
		lv_label_set_text(obj,user_data_char);
	}
		break;
	default:
		break;
	}
}

void events_init(lv_ui *ui)
{
	//时间更新
	lv_obj_add_event_cb(ui->screenHome_labeldate,datetime_charge_handler,LV_EVENT_VALUE_CHANGED,ui);
	//设备编号
	lv_obj_add_event_cb(ui->screenHome_label_1,deviceid_charge_handler,LV_EVENT_VALUE_CHANGED,ui);
	//人员编号
	lv_obj_add_event_cb(ui->screenHome_label_2,personid_charge_handler,LV_EVENT_VALUE_CHANGED,ui);
	//焊口编号
	lv_obj_add_event_cb(ui->screenHome_label_3,weldid_charge_handler,LV_EVENT_VALUE_CHANGED,ui);
	//方向
	lv_obj_add_event_cb(ui->screenHome_label_4,direction_charge_handler,LV_EVENT_VALUE_CHANGED,ui);
	//焊层
	lv_obj_add_event_cb(ui->screenHome_label_5,weldlayer_charge_handler,LV_EVENT_VALUE_CHANGED,ui);
	//角度
	lv_obj_add_event_cb(ui->screenHome_label_7,angle_charge_handler,LV_EVENT_VALUE_CHANGED,ui);
	//电压
	lv_obj_add_event_cb(ui->screenHome_label_8,voltage_charge_handler,LV_EVENT_VALUE_CHANGED,ui);
	//电流
	lv_obj_add_event_cb(ui->screenHome_label_6,current_charge_handler,LV_EVENT_VALUE_CHANGED,ui);
	//焊接速度
	lv_obj_add_event_cb(ui->screenHome_label_9,weldspeed_charge_handler,LV_EVENT_VALUE_CHANGED,ui);
	//送丝速度
	lv_obj_add_event_cb(ui->screenHome_label_10,letspeed_charge_handler,LV_EVENT_VALUE_CHANGED,ui);
	//热输入
	lv_obj_add_event_cb(ui->screenHome_label_11,hotinput_charge_handler,LV_EVENT_VALUE_CHANGED,ui);
}



//lv_event_send(ui->screenHome_labeldate, LV_EVENT_VALUE_CHANGED, NULL);
